package com.example.Controller;

import com.example.Service.impl.TaskServiceImpl;
import com.example.util.Result;
import com.example.pojo.Task;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/task") //子路由  ->  /task
@Api(tags = "生产部门")
public class TaskController {

    @Autowired
    private TaskServiceImpl taskService;



    @GetMapping("/selectAll")
    public Result selectAll() {
        List<Task> taskList = taskService.selectAll();
        return new Result("200", "查询成功", taskList);
    }

    @GetMapping("/selectByTaskName")
    public Result selectByTaskName(@RequestParam(value = "taskName") String taskName) {
        System.out.println(taskName);
        List<Task> taskList = taskService.selectByTaskName(taskName);
        return new Result("200", "查询成功", taskList);
    }

    //发布任务的接口
    @PostMapping("/taskAdd")
    public Result taskAdd(@RequestBody Task task) {
        taskService.taskAdd(task);
        return new Result("200", "发布成功", null);
    }


    //监督任务菜单用的接口    supervise
    //我的分管的 分类的任务数量
    @GetMapping("/supervise")
    public Result taskSupervise() {
        List<Task> taskList = taskService.selectCalssifyNumber();
        return new Result("200","发布成功", taskList);
    }

    //展示所有任务
    @GetMapping("/selectAllTask")
    public Result selectAllTask(){
        List<Task> taskList = taskService.selectAllTask();
        return new Result("200","发布成功", taskList);
    }

    //展示即将超期的任务  任务开始时间 还有3天接近 结束时间
    @GetMapping("/selectUpcomingTask")
    public Result selectUpcomingTask() {
        List<Task> taskList = taskService.selectUpcomingTask();
        return new Result("200","发布成功", taskList);
    }

    //展示所有超期的任务
    @GetMapping("/selectExceedTask")
    public Result selectExceedTask() {
        List<Task> taskList = taskService.selectExceedTask();
        return new Result("200","发布成功", taskList);
    }

    //展示echarts 任务分布 图数据接口
    @GetMapping("/selectTaskEcharts")
    public Result selectTaskEcharts() {
        List<Task> taskList = taskService.selectTaskEcharts();
        return new Result("200","发布成功",taskList);
    }

}
